package com.zx._10_设计模式.行为型模式.观察者模式.demo2;

import java.util.ArrayList;
import java.util.List;

public class ListenerWapper {

    private List<Listener> listeners;

    public ListenerWapper() {
        listeners = new ArrayList<>();
    }

    public void register(Listener listener) {
        listeners.add(listener);
    }

    public void handler() {
        for (Listener listener : listeners) {
            if (listener != null) {
                listener.run();
            }
        }
    }

}
